package com.finalterm.payment.config;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 支付配置属性
 */
@Slf4j
@Data
@Component
@RefreshScope
@ConfigurationProperties(prefix = "payment")
public class PaymentConfigProperties {
    
    /**
     * 支付超时时间（秒）
     */
    private Integer timeout = 300;
    
    @PostConstruct
    public void init() {
        log.info("支付配置初始化完成，超时时间: {}秒", timeout);
    }
    
    /**
     * 设置超时时间，并记录配置变更
     */
    public void setTimeout(Integer timeout) {
        Integer oldTimeout = this.timeout;
        this.timeout = timeout;
        log.info("支付超时配置已更新: {}秒 -> {}秒", oldTimeout, timeout);
    }
}
